package DP.builder.car.product;

import java.util.ArrayList;

/**
 * @author msi
 * 车辆模型的抽象类
 */
public abstract class CarModel {
    //这个参数决定了各个基本方法执行的顺序、
    private ArrayList<String> sequence = new ArrayList<>();

    protected abstract void start();

    protected abstract void stop();

    protected abstract void alarm();

    protected abstract void engineBoom();

    final public void run(){
        //循环一边，谁在前，就先执行谁
        for (String s : sequence) {
            if("start".equalsIgnoreCase(s)){
                this.start();//启动汽车
            }else if("stop".equalsIgnoreCase(s)){
                this.stop();//停止汽车
            }else if("alarm".equalsIgnoreCase(s)){
                this.alarm();//喇叭开始叫
            }else if("engine boom".equalsIgnoreCase(s)){
                this.engineBoom();//引擎开始启动
            }
        }
    }

    //把传递过来的值传递到类中
    final public void setSequence(ArrayList<String> sequence){
        this.sequence=sequence;
    }
}
